<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * @property int $deletetime
 * @property int $id
 * @property int $like
 * @property int $movie_id 电影
 * @property int $pid
 * @property int $to_user_id
 * @property int $user_id
 * @property string $content
 * @property string $createtime
 * @property-read \app\model\MovieComment[] $child
 * @property-read \app\model\User $to_user
 * @property-read \app\model\User $user
 * @property-read \app\model\UserLike $user_like
 * @method static \think\db\Query onlyTrashed()
 * @method static \think\db\Query withTrashed()
 * @mixin \think\Model
 */
class MovieComment extends Model
{
	use SoftDelete;
	protected $createTime = 'createtime';
	protected $deleteTime = 'deletetime';
	
	function child()
	{
		return $this->hasMany(MovieComment::class,'pid');
	}
	
	function user()
	{
		return $this->belongsTo(User::class,'user_id');
	}
	
	function toUser()
	{
		return $this->belongsTo(User::class,'to_user_id');
	}
	
	function userLike()
	{
		return $this->hasOne(UserLike::class,'pro_id')->where(['type'=>4]);
	}

}
